package com.grad.webstudy.utils;

import java.util.Random;

/**
 * @Author: zjf
 * @Date: 2020/1/18 20:38
 * @Description:
 */
public class CodeUtils {

    public static String getRandomCode() {
        String numberList = "1234567890";
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            int index =0;
            if (i==0){
                index = random.nextInt(numberList.length()-1);
            }else{
                index = random.nextInt(numberList.length());
            }
            char c = numberList.charAt(index);
            result += c;
        }
        return result;

    }

    public static String getMoreRandomCode(){
        String numberList = "asdfghjklzxcvbnmqwertyuiop1234567890";
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            int index = random.nextInt(numberList.length());
            char c = numberList.charAt(index);
            result += c;
        }
        return result;
    }


    public static void main(String[] args) {
        CodeUtils test2 = new CodeUtils();
        System.out.println(test2.getRandomCode());

    }

}
